Truncate timestamp

by: Chill59, 8 years ago


I have created a bar chart with the following code but the x axis shows the complete timestamp, whereas I just want to show years.  For example, I want to show '2008', not '2008-01-01- 00:00:00'.  Any pointers on this would be greatly appreciated.


import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from matplotlib.dates import DateFormatter
import datetime as dt

df_annual_lang = pd.read_csv('annual_lang_count.csv', parse_dates=[0], names =['year', 'count'])
df_count_lang = df_annual_lang.set_index('year')
df_bar = df_count_lang.plot(kind='bar', title="Count of Cool Stuff",legend=None)
plt.show()




You must be logged in to post. Please login or register an account.